home *** CD-ROM | disk | FTP | other *** search
/ Champak 132 (Alt) / Vol 132.iso / games / pupworld.swf / scripts / __Packages / Heroes / Box.as < prev    next >
Encoding:
Text File  |  2011-06-09  |  1.8 KB  |  87 lines

  1. class Heroes.Box
  2. {
  3.    var x;
  4.    var y;
  5.    var z;
  6.    var w;
  7.    var h;
  8.    var b;
  9.    function Box(x, y, z, w, h, b)
  10.    {
  11.       this.setLocation(x,y,z);
  12.       this.setSize(w,h,b);
  13.    }
  14.    function setLocation(x, y, z)
  15.    {
  16.       this.x = x;
  17.       this.y = y;
  18.       this.z = z;
  19.    }
  20.    function setSize(w, h, b)
  21.    {
  22.       this.w = w;
  23.       this.h = h;
  24.       this.b = b;
  25.    }
  26.    function isHitting(myBox)
  27.    {
  28.       var _loc3_ = 0;
  29.       if(myBox.x < this.x + this.w)
  30.       {
  31.          _loc3_ = _loc3_ + 1;
  32.       }
  33.       if(myBox.x + myBox.w > this.x)
  34.       {
  35.          _loc3_ = _loc3_ + 1;
  36.       }
  37.       if(myBox.y + myBox.h > this.y)
  38.       {
  39.          _loc3_ = _loc3_ + 1;
  40.       }
  41.       if(myBox.y < this.y + this.h)
  42.       {
  43.          _loc3_ = _loc3_ + 1;
  44.       }
  45.       if(myBox.z + myBox.b > this.z)
  46.       {
  47.          _loc3_ = _loc3_ + 1;
  48.       }
  49.       if(myBox.z < this.z + this.b)
  50.       {
  51.          _loc3_ = _loc3_ + 1;
  52.       }
  53.       if(_loc3_ == 6)
  54.       {
  55.          return true;
  56.       }
  57.       return false;
  58.    }
  59.    function isTouching(px, py, pz)
  60.    {
  61.       if(px < this.x + this.w)
  62.       {
  63.          if(px > this.x)
  64.          {
  65.             if(py > this.y)
  66.             {
  67.                if(py < this.y + this.h)
  68.                {
  69.                   if(pz > this.z)
  70.                   {
  71.                      if(pz < this.z + this.b)
  72.                      {
  73.                         return true;
  74.                      }
  75.                   }
  76.                }
  77.             }
  78.          }
  79.       }
  80.       return false;
  81.    }
  82.    function toString()
  83.    {
  84.       return Math.round(this.w) + "*" + Math.round(this.h) + "*" + Math.round(this.b) + " @ (" + Math.round(this.x) + "," + Math.round(this.y) + "," + Math.round(this.z) + ")";
  85.    }
  86. }
  87.